<template>
  <rx-dialog @handOk="handOk" @cancel="cancel">
    <rx-layout>
      <div slot="header"  >
        <div class="table-page-search-wrapper">
          <a-form layout="inline">
            <a-row :gutter="48">
              <a-col :span="12">
                <a-form-item :label="$ti18('rxForm.name','名称')">
                  <a-input :placeholder="$ti18('rxForm.name','名称','','input')" v-model="queryParam.Q_NAME__S_LK" />
                </a-form-item>
              </a-col>
              <a-col  :span="12">
              <span class="table-page-search-submitButtons">
                <a-button type="primary" @click="$refs.table.loadData()" icon="search">{{$ti18('rxList.searchBtn','查询')}}</a-button>
                <a-button style="margin-left: 4px" @click="resetSearch">{{$ti18('rxList.resetBtn','重置')}}</a-button>
              </span>
              </a-col>
            </a-row>
          </a-form>
        </div>
      </div>

      <div slot="center" style>
        <rx-grid
          ref="table"
          :allowRowSelect="true"
          :multiSelect="multiSelect"
          :columns="columns"
          :defaultPageSize="10"
          url="/api-ureport/ureport2/core/ureportFile/query"
          :queryParam="queryParam"
          data-field="result.data"
          :pageSizeOptions="['10','30','40']"
          id-field="id"
          @selectChange="onSelectChange"
        >
        </rx-grid>

      </div>
    </rx-layout>
  </rx-dialog>
</template>

<script>

import UreportFile from "@/api/form/core/ureportFile";

import {BaseList, RxLayout, Util,JsConstant} from "@lowcode/jpaas-common-lib"

export default {
    name: 'UreportListDialog',
    mixins: [BaseList],
    components: {
        RxLayout
    },
    props: {
      layerid: {
        type: String,
        default: ""
      },
      destroy: {
        type: Function
      },
      multiSelect:{
        type: Boolean,
        default: true
      },
      appId:{
          type: String,
          default: ""
      }
    },
    data() {
      return {
        columns: [
          {
            title: this.$ti18('rxList.index','序号'),
            type: 'indexColumn',
            width: 100,
            dataIndex: 'serial',
            scopedSlots: {customRender: 'serial'}
          },
          {title: this.i18n('form.reportName','报表名称'), dataIndex: 'name', width: 100}
        ],
      }

    },
    created(){
        if (this.appId){
            this.queryParam.Q_APP_ID__S_EQ=this.appId;
        }
    },
    methods: {
      i18n(name,text,key){
          return this.$ti18(name,text,"UreportDef",key);
      },
      cancel(){
        Util.closeWindow(this,"cancel");
      },
        async handOk() {
            var rows = this.selectedRows;
            if (rows.length == 0) {
                this.$message.warning(this.$ti18('rxMsa.masWarn.selectOneRecord', '请选择一行记录!'));
                return;
            }
            let row = rows[0];
            let id = row.id;
            let rtn = await UreportFile.get(id);
            let ary = [rtn.data]
            Util.closeWindow(this, "ok", ary);
        }
    }
  }
</script>
<style  scoped >

</style>

